<?php
/**
 * User: @lose
 * Date: 2019-10-10
 * Time: 18:00
 */

namespace Biz\model\store;

use Doraemon\pockets\datebase\BaseDbModel;

class StoreAuth extends BaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';

    const _CONFIG_SELECT_ = 'db_store';

    const _DATABASE_ = 'store';

    const _TABLE_NAME = 'store_auth';


    const BRAND_TYPE = 1;//品牌方
    const AGENT_TYPE = 2;//代理方
    const SERVER_TYPE_MAP = [
        self::BRAND_TYPE =>"品牌方",
        self::AGENT_TYPE => '代理商'
    ];

    public static function getListByWhere($where, $field = '*')
    {
        return self::select($field, $where);
    }

    public static function getListByAdmin($where, $limit)
    {
        return self::select('*', [
            'AND' => $where,
            'LIMIT' => $limit
        ]);
    }

    public static function add($data)
    {
        $result = self::insert($data)->rowCount();
        if($result) {
            return self::id();
        }

        return false;
    }

    public static function updateById($id, $data)
    {
        $result = self::update($data, ['id' => $id])->rowCount();
        if($result) {
            return $id;
        }

        return false;
    }

    public static function getInfo($id)
    {
        return self::get('*', ['id' => $id]);
    }

    public static function getCount($where)
    {
        return self::count($where);
    }

    public static function getInfoByAid($account_id)
    {
        return self::get('*', ['account_id' => $account_id]);
    }



}